package com.zhangh.summer.admin.support.prometheus;

import io.prometheus.client.Counter;
import io.prometheus.client.Summary;

/**
 * @description: TODO
 * @author: zhanghui  zhanghlucky@163.com
 * @create: 2020-07-01 11:33
 **/
public class MetricsExporter {
    private final Counter grpcRequestTotal = (Counter)((Counter.Builder)((Counter.Builder)((Counter.Builder) Counter.build().name("grpc_requests_total")).labelNames(new String[]{"method", "handler", "status"})).help("Http Request Total")).register();
    private final Summary grpcResponseTimeInMs = (Summary)((io.prometheus.client.Summary.Builder)((io.prometheus.client.Summary.Builder)((io.prometheus.client.Summary.Builder) Summary.build().name("grpc_response_time_milliseconds")).labelNames(new String[]{"method", "handler", "status"})).help("Request completed time in milliseconds")).register();
    private final Counter requestTotal = (Counter)((Counter.Builder)((Counter.Builder)((Counter.Builder) Counter.build().name("http_requests_total")).labelNames(new String[]{"method", "handler", "status"})).help("Http Request Total")).register();
    private final Summary responseTimeInMs = (Summary)((io.prometheus.client.Summary.Builder)((io.prometheus.client.Summary.Builder)((io.prometheus.client.Summary.Builder) Summary.build().name("http_response_time_milliseconds")).labelNames(new String[]{"method", "handler", "status"})).help("Request completed time in milliseconds")).register();

    private static MetricsExporter instance;

    private MetricsExporter (){

    }

    public static synchronized MetricsExporter getInstance() {
        if (instance == null) {
            instance = new MetricsExporter();
        }
        return instance;
    }

    public Counter getGrpcRequestTotal() {
        return this.grpcRequestTotal;
    }

    public Summary getGrpcResponseTimeInMs() {
        return this.grpcResponseTimeInMs;
    }

    public Counter getRequestTotal() {
        return this.requestTotal;
    }

    public Summary getResponseTimeInMs() {
        return this.responseTimeInMs;
    }

}
